package com.jarvis.hospital.prescription.adapter;

import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jarvis.hospital.R;
import com.jarvis.hospital.prescription.model.BloodDetailModel;
import com.jarvis.hospital.prescription.model.BloodTimeModel;
import com.jarvis.hospital.prescription.model.PrescriptionTimeDetailModel;

import java.util.List;

/**
 * Created by jarvis.liu on 9/12/2016.
 */
public class PrescriptionBloodAdapter extends BaseQuickAdapter<BloodTimeModel> {
    public PrescriptionBloodAdapter(int layoutResId, List<BloodTimeModel> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, BloodTimeModel bloodTimeModel) {

        baseViewHolder
                .setText(R.id.tv_title, "采血起"+bloodTimeModel.getBloodInterval()+"h")
                .setText(R.id.tv_title_1, "采血起"+bloodTimeModel.getBloodInterval()+"h")
                .setText(R.id.tv_time, bloodTimeModel.getDrawTimeDo())
                .setText(R.id.tv_analysis, bloodTimeModel.getAnalysisText())
                .setText(R.id.tv_plan_time, bloodTimeModel.getDrawTimePlan())
                .addOnClickListener(R.id.img_analysis);;
        ImageView img_analysis = baseViewHolder.getView(R.id.img_analysis);
        LinearLayout lin_done = baseViewHolder.getView(R.id.lin_done);
        RelativeLayout rel_undo = baseViewHolder.getView(R.id.rel_undo);
        if(TextUtils.isEmpty(bloodTimeModel.getAnalysisPic())){
            rel_undo.setVisibility(View.VISIBLE);
            lin_done.setVisibility(View.GONE);
        }else {
            rel_undo.setVisibility(View.GONE);
            lin_done.setVisibility(View.VISIBLE);
        }
        Glide.with(mContext)
                .load(bloodTimeModel.getAnalysisPic())
                .error(R.drawable.img_main_bg)
                .into(img_analysis);
    }
}
